<?php
/**
 * Created by PhpStorm.
 * User: 程阳
 * Date: 2017/2/22
 * Time: 20:46
 */

namespace Admin\Controller;


use Common\Controller\AdminController;

class BrandController extends AdminController
{
    public function lists(){
        $listsData = D('Brand')->select();
        $this->assign('listsData',$listsData);
        $this->display();
    }

    public function addBrand(){
        $bid = I('get.bid');
        if(IS_POST){
            $data = I('post.');
            if($bid){
                $data['bid'] = $bid;
            }
            $this->store(D("Brand"),$data,function(){
                $this->success('类型提交成功',u('admin/Brand/lists'));die;
            });
        }
        if($bid){
            $oldData = D('Brand')->where('bid='.$bid)->find();
            $this->assign('oldData',$oldData);
        }
        $this->display();
    }

    public function delBrand(){
        $bid = I('post.id');
        $res = D('Brand')->delete($bid);
        if($res){
            return show(1,'删除成功');
        }else{
            return show(0,'删除失败');
        }
    }

    public function upload(){
        parent::upload();
    }
}